package com.xuxk.project.library.service.impl;
import java.util.HashMap;
import java.util.List;
import com.github.pagehelper.Page;
import org.apache.ibatis.session.RowBounds;
import java.util.Map;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import com.xuxk.project.library.dao.RoleMenuDao;
import com.xuxk.project.library.bean.RoleMenu;
import com.xuxk.project.library.dto.RoleMenuDto;
import com.xuxk.project.library.vo.RoleMenuVo;
import com.xuxk.project.library.service.RoleMenuService;


/**
 * Manager implementation for RoleMenu, responsible for business processing, and communicate between web and persistence layer.
 * @author 橙云科技有限公司
 */
@Service
public class RoleMenuServiceImpl implements RoleMenuService {

	@Resource
	private RoleMenuDao roleMenuDao;
    @Override
	public Page<RoleMenuVo>  listRoleMenus(Map<String, Object> map, RowBounds rowBounds){


        Page<RoleMenuVo> roleMenuPage =  roleMenuDao.listRoleMenus(map,rowBounds);
		return roleMenuPage;
	}
    @Override
	public List<RoleMenu> listRoleMenuByDto(RoleMenuDto dto){
        /**
         * 使用例子：
		 *
         * OaEmployeeDto dto1 = new OaEmployeeDto();
         * 		dto1.createCriteria()
         * 			.andIdEqualTo(1L)
         * 			.andFnumberEqualTo("NLW17004");
         * 	roleMenuDao.listByDto(dto1);
         */

		return roleMenuDao.listByDto(dto);
	}

    @Override
	public void deleteRoleMenu(Integer id )  {
	    Map<String,Object> map = new HashMap<>();
        map.put("id",id);


		roleMenuDao.deleteByPrimaryKey(map);
	}

    /**
    * 全量更新
    * @return
    */
    @Override
    public Integer updateRoleMenu(RoleMenu roleMenu)  {



        return roleMenuDao.updateRoleMenu(roleMenu);
    }

    /**
    * 部分更新
	* @return
	*/
    @Override
    public Integer patchUpdateRoleMenu(RoleMenu roleMenu)  {

        return roleMenuDao.patchUpdateRoleMenu(roleMenu);

    }

    /**
    * 新增
	* @return
	*/
    @Override
    public Integer insertRoleMenu(RoleMenu roleMenu)  {


		roleMenuDao.insertSelective(roleMenu);

        return roleMenu.getId();

    }
    @Override
    public RoleMenu getRoleMenu(Integer id){
        Map<String,Object> map = new HashMap<>();
        map.put("id",id);
        return roleMenuDao.getRoleMenu(map);
    }

}